package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.NoteDTO;
import com.tianji.learning.domain.query.NotePageQuery;
import com.tianji.learning.domain.vo.NoteVO;
import com.tianji.learning.service.INoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 笔记表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-04-25
 */
@RestController
@RequestMapping("/notes")
@Api(tags = "笔记表接口")
@RequiredArgsConstructor
public class NoteController {
    private final INoteService noteService;

    @PostMapping
    @ApiOperation("新增笔记")
    public void saveNote(@RequestBody @Validated NoteDTO noteDTO) {
        noteService.saveNote(noteDTO);
    }
    @PostMapping("/gathers/{id}")
    @ApiOperation("采集笔记")
    public void gatherNote(@PathVariable Long id) {
        noteService.gatherNote(id);
    }
    @DeleteMapping("/gathers/{id}")
    @ApiOperation("取消采集的笔记")
    public void cancelGatherNote(@PathVariable Long id) {
        noteService.cancelGatherNote(id);
    }
    @PutMapping("/{id}")
    @ApiOperation("修改笔记")
    public void updateNote(@PathVariable Long id, @RequestBody NoteDTO noteDTO) {
        noteService.updateNote(id, noteDTO);
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除我的笔记")
    public void deleteNote(@PathVariable Long id) {
        noteService.removeById(id);
    }
    @GetMapping("/page")
    @ApiOperation("分页查询笔记-用户端")
    public PageDTO<NoteVO> queryNote(NotePageQuery query){
        return noteService.queryNote(query);
    }

}
